import request from '@/utils/request'

// 获取权限树
export function getPermissionTree() {
  return request.get('/admin/permission/tree')
}

// 获取用户菜单树
export function getUserMenuTree() {
  return request.get('/admin/permission/user/menus')
}

// 获取所有权限列表
export function getAllPermissions() {
  return request.get('/admin/permission/list')
}

// 根据ID获取权限
export function getPermissionById(id) {
  return request.get(`/admin/permission/${id}`)
}

// 新增权限
export function addPermission(data) {
  return request.post('/admin/permission', data)
}

// 更新权限
export function updatePermission(data) {
  return request.put('/admin/permission', data)
}

// 删除权限
export function deletePermission(id) {
  return request.delete(`/admin/permission/${id}`)
}

// 获取用户权限编码列表
export function getPermissionCodesByUserId(userId) {
  console.log('API调用 - 获取权限编码, userId:', userId)
  return request.get(`/admin/permission/codes/${userId}`)
}

// 获取当前用户的菜单和权限信息
export function getCurrentUserPermissionInfo() {
  return request.get('/admin/permission/user/info')
}
